<!DOCTYPE html>
<?php
include_once("inc/constants.inc.php");
include_once("inc/connection.php");
session_start();

	if(!isset($_SESSION['login']) || empty($_SESSION['login']) || !isset($_SESSION['email']) || empty($_SESSION['email']) || !isset($_SESSION['user_role']))
		{
			header("Location: login.php?error=invalid-access");
			exit(0);
		}
	elseif($_SESSION['user_role']==2)
		{
			header("Location: test.php?error=invalid-access");
			exit(0);
		}
	if(isset($_GET['isNumeric']) && $_GET['isNumeric']=="no")
		{
			$isNumeric = false;
		}
	elseif(isset($_GET['isUpdated']) && $_GET['isUpdated']=="yes")
		{
			$isUpdated = true;
		}
	/*
	elseif(isset($_GET['type']) && isset($_GET['isNumeric']) && $_GET['isNumeric']=="no" && $_GET['type']=="technical")
		{
			$isTechNumeric = false;
		}
	elseif(isset($_GET['type']) && isset($_GET['isUpdated']) && $_GET['isUpdated']=="yes" && $_GET['type']=="aptitude")
		{
			$isAptiUpdated = true;
		}
	elseif(isset($_GET['type']) && isset($_GET['isUpdated']) && $_GET['isUpdated']=="yes" && $_GET['type']=="technical")
		{
			$isTechUpdated = true;
		}
	
	$result = mysql_query("SELECT * FROM exam_config WHERE typeId=1");	
	while($row = mysql_fetch_array($result))
		{
			$aptitudeTime = $row['examTime'];
			$aptitudeTime = $aptitudeTime/60;
			$aptitudeTime = $aptitudeTime/1000;
		}
	$result = mysql_query("SELECT * FROM exam_config WHERE typeId=2");	
	while($row = mysql_fetch_array($result))
		{
			$technicalTime = $row['examTime'];
			$technicalTime = $technicalTime/60;
			$technicalTime = $technicalTime/1000;
		}
	*/

?>
<html>
	<head>
		<meta charset="utf-8"> 
		<title>Smartek online test | Manage Time</title>
		<link rel="SHORTCUT ICON" href="img/disp/favicon.png" />	
		<link rel="stylesheet" href="css/bootstrap.css"  type="text/css"/>
		<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
		<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
		<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
		<script src="js/bootstrap.js"></script>
		<script>
			$(function() {
				$( "#accordion" ).accordion({
					heightStyle: "content"
				});
			});
		</script>
		
	</head>
	<body>

		<div class="container">
			<a href="index.php"><img src="img/disp/logo.png" alt=""></a>
		</div>
		
		<div class="container">
			<div class="row pull-right">
				<div class="span4 pull-right" >
					<div class="pull-right">
						<?php 
						if(!isset($_SESSION['name']) || empty($_SESSION['name'])) echo  "<a href='login.php'>Login</a>";
						if(isset($_SESSION['name']) && !empty($_SESSION['name']) && isset($_SESSION['user_role']) && $_SESSION['user_role']==1) echo  "Welcome ".$_SESSION['name']."! | <a href='dashboard.php'>Dashboard</a> | <a href='logout.php'>Log out</a>"; 
						if(isset($_SESSION['name']) && !empty($_SESSION['name']) && isset($_SESSION['user_role']) && $_SESSION['user_role']==2) echo  "Welcome ".$_SESSION['name']."! | <a href='test.php'>Continue test</a> | <a href='logout.php'>Log out</a>"; 
						?>
					</div>
				</div>
			</div>
		</div>	
		<div class="container">
			<hr class="featurette-divider">
		</div>
		<div class="container">
						<a href="select-type-admin.php">Add Question</a> 
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
						<a href="show-question-list.php">View Question List</a>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="manage-time.php">Manage Exam Time</a><br/><br/>
		</div>
		<div class="container">
			<?php
				if(isset($isNumeric) && !$isNumeric)
					{echo "<font color='red'>Please enter a numeric value</font><br/><br/>";}
				if(isset($isUpdated) && $isUpdated)
					{echo "<font color='blue'>Updated Successfully !</font><br/><br/>";}
			?>
		</div>
		<div class="container">
			<div class="row">
				<div class="span12" > <!--pagination-centered-->
					<div id="accordion">
						<?php
							$result = mysql_query("SELECT * FROM question_type WHERE isDeleted='no'");
							while($row = mysql_fetch_array($result))
							{
								$questionType = $row['QType'];
								$typeId = $row['QTypeID'];
								echo "<h3>Set Time for " . $questionType . "</h3>";
							?>
								<div id=". $questionType .">
									<p><br/>
										<form action="process/manage-time.php" method="POST">
										<?php											
											$req = mysql_query("SELECT * FROM exam_config WHERE typeId='$typeId'");
											while($res = mysql_fetch_array($req))
											{
												$time = $res['examTime'];
												$time = $time/60;
												$time = $time/1000;
										?>
											<input type="text" name="testTime" style="margin-bottom: 0" value="<?php if(isset($time)){echo $time;} ?>"> minute(s) <br/><br/>
										<?php } ?>
											<input type="hidden" name="typeId" value="<?php echo $typeId; ?>">
											<input type="submit" name="timeBtn" class='btn' value="Set Time"/>
										</form>
										<br/>
									</p>
								</div>
						<?php
							}
						?>
						
					<?php
					/*
					?>
						<h3>Set Time for Aptitude</h3>
						<div id="aptitude">
							<p>
								<br/>
								<form action="process/manage-time.php" method="POST">
								<?php
										if(isset($isAptiNumeric) && !$isAptiNumeric)
										{echo "<font color='red'>Please enter a numeric value</font><br/><br/>";}
										elseif(isset($isAptiUpdated) && $isAptiUpdated)
										{echo "<font color='blue'>Updated Successfully !</font><br/><br/>";}
								?>
									<input type="text" name="aptitudeText" style="margin-bottom: 0" value="<?php if(isset($aptitudeTime)){echo $aptitudeTime;} ?>"> minute(s) <br/><br/>
									<input type="submit" name="aptitudeTimeBtn" class='btn' value="Set Time"/>
								</form>
								<br/>
							</p>
						</div>
						<h3>Set Time for Technical</h3>
						<div id="technical">
							<p>
								<br/>
								<form action="process/manage-time.php" method="POST">
									<?php
										if(isset($isTechNumeric) && !$isTechNumeric)
										{echo "<font color='red'>Please enter a numeric value</font><br/><br/>";}
										elseif(isset($isTechUpdated) && $isTechUpdated)
										{echo "<font color='blue'>Updated Successfully !</font><br/><br/>";}
									?>
									<input type="text" name="technicalText" style="margin-bottom: 0" value="<?php if(isset($technicalTime)){echo $technicalTime;} ?>"> minute(s) <br/><br/>
									<input type="submit" name="technicalTimeBtn" class='btn' value="Set Time"/>
								</form>
								<br/>
							</p>
						</div>
					<?php
					*/
					?>
					</div>
				<br/><br/>
				
				<form action='dashboard.php'>
					<input type='submit' name='backToDashboard' class='btn' value='Back To Dashboard'> <br/>
				</form>


				</div>
			</div>
		</div>

		
		<div class="container marketing">
      <!-- FOOTER -->
		<div class="container">
			<hr class="featurette-divider">
		</div>
      <footer>
        <p>&copy; 2014 SCS &middot; </p>
      </footer>

    </div><!-- /.container -->
	</body>
</html>